package com.solidtrust.util;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ImageUtil {
	
	public final static int HEIGHT = 500;
	public final static int THUMBNAL_HEIGHT = 180;
	
	public static void resize(BufferedImage bi, File f, int height) throws IOException{
		int h = bi.getHeight();
		int w = bi.getWidth();
		
		Image i = bi.getScaledInstance(height * w / h, height, Image.SCALE_SMOOTH);
		BufferedImage newImage = new BufferedImage(height * w / h, height, BufferedImage.TYPE_3BYTE_BGR);
		Graphics2D g = newImage.createGraphics();
		g.drawImage(i, null, null);
		
		
		ImageIO.write(newImage, "jpg", f);
	}
}
